-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Emilio Augusto Veras Ivanovich
-- Create date: 04/30/2012
-- Description:	Insert new records into the table Type Of Samples
-- =============================================
CREATE PROCEDURE [dbo].[PROCEDURE_INSERT_UPDATE_TYPES_OF_SAMPLES]
	-- Add the parameters for the stored procedure here
	@ID tinyint = NULL,
	@DESCRIPTION varchar(100) = NULL, 
	@IS_ACTIVE bit = NULL
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
    -- Insert statements for procedure here
    IF @ID IS NULL
    BEGIN
		INSERT INTO [SGLL].[dbo].[TYPES_OF_SAMPLES]
			   ([DESCRIPTION]
			   ,[IS_ACTIVE]
			   ,[INSERTED]
			   ,[UPDATED])
		 VALUES
			   (@DESCRIPTION
			   ,@IS_ACTIVE
			   ,GETDATE()
			   ,GETDATE());
    END
    ELSE
    BEGIN
		UPDATE [SGLL].[dbo].[TYPES_OF_SAMPLES]
			SET  [DESCRIPTION] = @DESCRIPTION
				,[IS_ACTIVE] = @IS_ACTIVE
				,[UPDATED] = GETDATE()
		 WHERE [ID] = @ID
    END
END
GO